using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_Receipt_VoucherMap : EntityTypeConfiguration<SO_Receipt_Voucher>
    {
        public SO_Receipt_VoucherMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Account, t.CURRENCY, t.Account_Description, t.Date });

            // Properties
            this.Property(t => t.Batch)
                .HasMaxLength(10);

            this.Property(t => t.Serial_Number)
                .HasMaxLength(6);

            this.Property(t => t.Account)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.CURRENCY)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Payment_Type)
                .HasMaxLength(11);

            this.Property(t => t.Account_Description)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Transaction_Description)
                .HasMaxLength(123);

            // Table & Column Mappings
            this.ToTable("SO_Receipt_Voucher");
            this.Property(t => t.Batch).HasColumnName("Batch");
            this.Property(t => t.Serial_Number).HasColumnName("Serial_Number");
            this.Property(t => t.Account).HasColumnName("Account");
            this.Property(t => t.Debitacct).HasColumnName("Debitacct");
            this.Property(t => t.Creditacct).HasColumnName("Creditacct");
            this.Property(t => t.Debit).HasColumnName("Debit");
            this.Property(t => t.Credit).HasColumnName("Credit");
            this.Property(t => t.Debitdol).HasColumnName("Debitdol");
            this.Property(t => t.Creditdol).HasColumnName("Creditdol");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.Payment_Type).HasColumnName("Payment_Type");
            this.Property(t => t.Account_Description).HasColumnName("Account Description");
            this.Property(t => t.Transaction_Description).HasColumnName("Transaction Description");
            this.Property(t => t.Date).HasColumnName("Date");
        }
    }
}
